<template>
  <c-row-view class="wot-linkage" title="数据联动">
    <template #opn>
      <LinkageAdd :data="data" @submit="updateTable"></LinkageAdd>
    </template>
    <c-table index height="250px" :col="col">
      <template #opn="{ row }">
        <el-button type="text" @click="edit(row)">
          <c-icon name="edit"></c-icon>
          <span>
            {{ multLang('btn_edit_a') }}
          </span>
        </el-button>
        <el-button type="text" @click="del(row)">
          <c-icon name="delete"></c-icon>
          <span>
            {{ multLang('btn_delete_a') }}
          </span>
        </el-button>
      </template>
    </c-table>
  </c-row-view>
</template>
<script>
// export const a = {
//   exList: [
//     {
//       field_name: '属性名称/taskRight',
//       field_write_type: '属性类型 /写入只读权限/日期类型/小数点位数/',
//       field_value: '属性值'
//     }
//   ],
//   linkList: [
//     {
//       linkage_type: '联动类型：1：界面内容；2：接口；3：自定义；',
//       link_field_form_code: '联动字段主键 ；当 linkage type 为1时传值',
//       self_defined: '自定义 ；当 linkage type 为3时传值',
//       interface_address: '接口地址：各业务方法 ；当 linkage type 为2时传值',
//       condition: '条件字段，包含顶部联动控件和来源为接口时的参数设置，详情见下'
//     }
//   ],
//   condition: {
//     top: '顶部的联动空间，集合格式，字段未定义',
//     interface: '来源为接口时的参数，集合格式，字段为定义'
//   }
// }
import LinkageAdd from './LinkageAdd.vue'
export default {
  name: 'Linkage',
  components: { LinkageAdd },
  props: {
    data: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {}
  },
  computed: {
    sourceModeMap() {
      return this.optionMap('source_mode')
    },
    col() {
      return [
        {
          label: '数据来源',
          prop: 'linkage_type',
          formatter: (row, { property }) => this.sourceModeMap[row[property]]
        }
      ]
    }
  },
  watch: {},
  beforeCreate() {},
  created() {
    this.setOption({ key: 'source_mode' })
  },
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  activated() {},
  deactivated() {},
  beforeDestroy() {},
  destroyed() {},
  methods: {
    edit() {},
    del() {},
    updateTable(data) {
      this.table.data.push(data)
      this.submit()
    },
    submit() {
      this.$emit('submit', this.table.data)
    }
  }
}
</script>
<style lang="scss">
.wot-linkage {
}
</style>
